package com.assembler.app;

import java.awt.BorderLayout;
import java.util.List;

import javax.swing.JApplet;
import javax.swing.JFrame;

import com.assembler.app.debruij.DeBruijnGraph;
import com.assembler.app.genome.Genome;
import com.assembler.app.genome.GenomeFileHelper;
import com.assembler.app.sort.TopologicalSort;

/**
 * This class is entry point to visual applet application.
 * 
 * This class is a part of the lab rotation project for PhD  students in January 2014.
 * School of Computing
 * National University Singapore.
 * 
 * @author Iana Pyrogova, Abha Belorkar
 * @version 1.0.1
 */

public class MainApp {
	public static void main(String[] args) {

		//String sequence = "TACGACGTCGACT";
		int k= 12;
		GenomeFileHelper genomeFileHelper = new GenomeFileHelper();
		long start = System.currentTimeMillis();
		Genome genome = genomeFileHelper.readFromTxtFile("ecoli_genome.txt");
		System.out.println("1. File read took " + (System.currentTimeMillis()-start));
		
		start = System.currentTimeMillis();
		List<String> kmers = GenomAssembler.buildKMers(genome.getGenom(), k);
		System.out.println("2. 'GenomAssembler.buildKMers' took " + (System.currentTimeMillis()-start));
		
		start = System.currentTimeMillis();
		DeBruijnGraph graph = GenomAssembler.getDeBruijnGraph(kmers, true);
		System.out.println("3. 'GenomAssembler.getDeBruijnGraph' took " + (System.currentTimeMillis()-start));
		
		start = System.currentTimeMillis();
		System.out.println("Start Sorting");
		TopologicalSort.runSorting(graph);
		System.out.println("3. 'TopologicalSort.runSorting(graph)' took " + (System.currentTimeMillis()-start));
//		JApplet grApplet = new DeBruijnGraphApplet();
//		((DeBruijnGraphApplet) grApplet).setGraph(graph);
//
//		JFrame mainFrame = new JFrame("DeBruijn Graph");
//		grApplet.init();
//		mainFrame.add(grApplet, BorderLayout.CENTER);
//		mainFrame.pack();
//		mainFrame.setVisible(true);
//		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		System.out.println("4. Applet rendering took " + (System.currentTimeMillis()-start));


	}
}